public class demo1 {
    class Solution {
        public int numDecodings(String ss) {
            char[]s=ss.toCharArray();
            int n=ss.length();
            int []dp=new int[n];
            if(s[0]!='0')dp[0]+=1;
            if(n==1)return dp[0];
            if(s[1]!='0'&&s[0]!='0')dp[1]+=1;
            int ret=(s[0]-'0')*10+(s[1]-'0');
            if(ret>=10&&ret<=26)dp[1]+=1;
            for(int i=2;i<n;i++){
                if(s[i]!='0')dp[i]+=dp[i-1];
                int ret1=(s[i-1]-'0')*10+(s[i]-'0');
                if(ret1>=10&&ret1<=26)dp[i]+=dp[i-2];
            }
            return dp[n-1];
        }
    }
}
